package com.snopy.collection.set.hashset;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

/**
 * @author snopy
 * @version 1.0.0
 * @classname DemoHashSet
 * @description 或许我还要再等第二份邮件的到来。感谢您的帮助。
 * @email 77912204@qq.com
 * @date 2022/07/28 14:22
 */
@Slf4j
public class DemoHashSet {

    public static void main(String[] args) {
        Set<String> uniques = new HashSet<>();
        Set<String> dups = new HashSet<>();
        for (String arg : args) {
            if (!uniques.add(arg)){
                dups.add(arg);
            }
        }
        uniques.removeAll(dups);
        log.info("uniques:{}",uniques);
        log.info("dups:{}",dups);

        /*Set<String> set = Arrays.asList(args).stream().collect(Collectors.toSet());
        log.info("set: {}",set);
        log.info("size:{}",set.size());*/
/*        Set<String> set = new HashSet<>();
        for (String arg : args) {
            set.add(arg);
        }
        log.info("set:{}",set);
        Set<String> set2 = new TreeSet<>();
        for (String arg : args) {
            set2.add(arg);
        }
        log.info("set2:{}",set2);*/
        /*String a = "a";
        String b = "b";
        String c = "c";
        String d = "d";
        String e = "e";
        Set<String> set1 = new HashSet<>();
        Set<String> set2 = new HashSet<>();
        set1.add(a);
        set1.add(b);
        set1.add(c);
        set1.add(d);
        set2.add(a);*/

        //log.info("subset set1 contains set2:{}",set1.containsAll(set2));
        /*set1.addAll(set2);
        log.info("union :{}",set1);*/
        //intersection
/*        set1.retainAll(set2);
        log.info("intersection s1:{}",set1);*/
        //asymmetric
        /*set1.removeAll(set2);
        log.info("asymmetric set1:{}",set1);*/
    }
}
